package com.lt.basic.project.admin.controller.sys;

import com.lt.basic.project.application.service.admin.sys.ISysLogsServer;
import com.lt.basic.project.common.core.AjaxResult;
import com.lt.basic.project.common.core.PageResult;
import com.lt.basic.project.pojo.validate.commons.PageValidate;
import com.lt.basic.project.pojo.validate.admin.sys.SysSearchLoginsValidate;
import com.lt.basic.project.pojo.validate.admin.sys.SysSearchOperateValidate;
import com.lt.basic.project.pojo.vo.admin.sys.SysLogLoginVo;
import com.lt.basic.project.pojo.vo.admin.sys.SysLogOperateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 系统日志管理
 * @author LT
 */
@RestController
@RequestMapping("admin/sys/log")
@Api(tags = "系统日志管理")
public class SysLogsController {

    @Resource
    ISysLogsServer iSysLogsServer;

    /**
     * 系统操作日志
     * @param pageValidate
     * @param searchValidate
     * @return
     */
    @GetMapping("/operate")
    @ApiOperation(value="系统操作日志")
    public AjaxResult<PageResult<SysLogOperateVo>> operate(@Validated PageValidate pageValidate,
                                                              @Validated SysSearchOperateValidate searchValidate) {
        PageResult<SysLogOperateVo> list = iSysLogsServer.operate(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    /**
     * 系统登录日志
     * @param pageValidate
     * @param searchValidate
     * @return
     */
    @GetMapping("/login")
    @ApiOperation(value="系统登录日志")
    public AjaxResult<PageResult<SysLogLoginVo>> login(@Validated PageValidate pageValidate,
                                                          @Validated SysSearchLoginsValidate searchValidate) {
        PageResult<SysLogLoginVo> list = iSysLogsServer.login(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

}
